﻿<%@ Page Language="C#" MasterPageFile="~/Manage/MainPage.master"  AutoEventWireup="true" CodeFile="CouponsManage.aspx.cs" Inherits="Manage_CouponsManage" %>
<%@ Import Namespace="Shopping.Common" %>
<%@ Import Namespace="Shopping.Model" %>
<%@ Import Namespace="System.Collections.Generic" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Content" Runat="Server">
<script type="text/javascript" src="/Manage/Js/CouponsManage.js"></script>
<script type="text/javascript" src="/Manage/Public/SelectUsers.js"></script>
<script type="text/javascript">
    StartDateOfCoupon = '<%=StartDateOfCoupon %>';
    EndDateOfCoupon = '<%=EndDateOfCoupon %>';
    ModelOfCoupon = <%=new Coupons().ToJsonString() %>;
    ModelOfUserCoupon = <%=new UserCoupons().ToJsonString() %>;
    SelectOptionOfUseStatus = '<%=SelectOptionOfUseStatus %>';
</script>


<table width="99%" border="0" cellspacing="0" cellpadding="0" class="table" align="center">
  <tr>
    <td align="center"><img src="/Manage/Images/sousuo.gif" />优惠劵编号：
      <input name="txtKeyWords" type="text" id="txtKeyWords" size="25" value="<%=q.KeyWords %>"  class="border6"/>
      使用状态：
      <select name="ddlUseStatusOfSearch" id="ddlUseStatusOfSearch">
        <option value="">-不限-</option>
        <%=SelectOptionOfUseStatus%>
      </select>
      是否已分配：
      <select name="ddlAllotStatusOfSearch" id="ddlAllotStatusOfSearch">
        <option value="">-不限-</option>
          <%=SelectOptionOfAllotStatus%>
        </select>
        是否已过期：
         <select name="ddlExpiredStatusOfSearch" id="ddlExpiredStatusOfSearch">
        <option value="">-不限-</option>
          <%=SelectOptionOfExpiredStatus%>
        </select>

        生成方式：
         <select name="ddlGenerateMethodOfSearch" id="ddlGenerateMethodOfSearch">
        <option value="">-不限-</option>
          <%=SelectOptionOfGenerateMethod%>
        </select>
      <input name="btnSearch" type="button" id="btnSearch" value="执行搜索" class="btn2" onclick="GoToSearch()" />
[ <a href="CouponsManage.aspx" class="red bold">查看全部</a> ] </td>
  </tr>
</table>
<table width="99%" border="0" cellspacing="0" cellpadding="0" class="table" align="center">
  <tr>
    <td colspan="11" align="left"   class="HeadTitle">&gt;&gt;优惠劵管理</td>
  </tr>
  <tr class="TableHeadRow">
    <td width="70" align="center">编号</td>
    <td align="center">优惠劵卡号</td>
    <td align="center">优惠劵金额</td>
    <td width="80" align="center">开始日期</td>
    <td width="80" align="center">结束日期</td>
    <td width="80" align="center">剩余天数</td>
    <td width="80" align="center">使用状态</td>
    <td width="100" align="center">所属会员</td>
    <td width="120" align="center">生成日期</td>
    <td width="60" align="center">生成方式</td>
    <td width="150" align="center">管理  [<a href="javascript:Add();" class="red">+生成优惠劵</a>] </td>
  </tr>

  <%
      if (listOfData != null)
      {
          Dictionary<string, string> dictUseStatusColor = new Dictionary<string, string>();
          dictUseStatusColor.Add(CouponUseStatus.未用.ToString(), "green");
          dictUseStatusColor.Add(CouponUseStatus.已用.ToString(), "red");
          for (int i = 0; i < listOfData.Count; ++i)
          {
              CouponInfo c = listOfData[i];
   %>
  <tr onmouseover="this.style.backgroundColor='#F2F2F2';" onmouseout="this.style.backgroundColor='#FFFFFF';">
    <td align="center"><%=(q.CurPage-1)*q.PageSize +i+1 %>.</td>
    <td align="center"><a href="javascript:Edit(<%=c.Coupon.CouponID %>);"><%=c.Coupon.CouponID %></a></td>
    <td align="center" class="blue bold"><%=c.Coupon.CouponMoney.ToString("C") %></td>
    <td align="center"><%=c.Coupon.StartDate.ToString("yyyy-MM-dd") %></td>
    <td align="center"><%=c.Coupon.EndDate.ToString("yyyy-MM-dd") %></td>
    <td align="center"><%=c.IsExpired?"<span class=\"red\">已过期</span>":c.剩余天数.ToString()+"天" %> </td>
    <td align="center" class="<%=dictUseStatusColor[c.Coupon.UseStatus] %>"><%=c.Coupon.UseStatus %></td>
    <td align="center"> 
    <%
        if (c.Owner == null)
            Response.Write("--");
        else
            Response.Write("<a href=\"UsersManage.aspx?KeyWords="+c.Owner.Name+"\" title=\"查看会员信息\">" + c.Owner.Name + "</a>");           
    %>
    
    </td>
    <td align="center"><%=c.Coupon.CreateDate.ToString("yyyy-MM-dd HH:mm:ss") %> </td>
    <td align="center"><%=c.Coupon.GenerateMethod %></td>
    <td align="center">[<a href="javascript:Assign(<%=c.Coupon.CouponID %>);" class="green">分配</a>] [<a href="javascript:Edit(<%=c.Coupon.CouponID %>);">编辑</a>] [<a href="javascript:Delete(<%=c.Coupon.CouponID %>);" class="red">删除</a>]  </td>
  </tr>
    <%} %>
   <tr>
    <td colspan="11" align="center"><span class="page" >
         <%=Utility.GetPageLine(Utility.GetWebPageUrlNoCurPage(), q.CurPage, q.PageSize, 10, q.TotalCount)%>        </span></td>
    </tr>
    <%}
     else
      { %>
  <tr>
    <td colspan="11" align="center">[ <span class="red bold">系统未找到任何优惠劵信息!</span> ]</td>
    </tr>
    <%} %>
</table>

</asp:Content>
